package yxy.cherry.battle.module.affix.skill;

import yxy.cherry.battle.Battle;
import yxy.cherry.battle.Fighter;
import yxy.cherry.battle.module.affix.AffixContext;
import yxy.cherry.battle.module.affix.AffixContext.AffixTarget;
import yxy.cherry.battle.module.affix.AffixFactory.SkillTypeEnum;
import yxy.cherry.battle.module.affix.Skill;
import yxy.cherry.battle.module.affix.SkillType;
import yxy.cherry.data.bean.skill;

import java.util.ArrayList;

/** 减伤 */
@SkillType(Type = SkillTypeEnum.减伤)
public class Affix_18_减伤 extends Skill {

	private int get减伤比例() {
		return getParam(0);
	}

	public Affix_18_减伤(Fighter actor, skill skilldata, int probability, int[] params) {
		super(actor, skilldata, probability, params);
	}

	@Override
	public boolean exec(Fighter source, Fighter target) {
		AffixContext.AffixAction affixAction = getAffixAction();

		if(target.equals(affixAction.get针对目标())) {
			AffixTarget affixTarget = getAffixAction().getTarget(source);
			ArrayList<Long> 结算伤害流 = genReduceDamage(affixTarget.get伤害流(), affixTarget.getBaseDamageList(), get减伤比例());

			Battle.battleLogger(6,"技能减伤：当前行动者："+affixAction.get行动者().getName()+"针对目标："+target.getName()+"总伤害："+affixTarget.get伤害流().toString()+"基本伤害"+affixTarget.getBaseDamageList().toString()+"减伤比例"+get减伤比例()+"减伤后："+结算伤害流.toString());

			affixTarget.set伤害流(结算伤害流);
		}

		return true;
	}
}